package com.cirkana.viewer.location;

import java.util.List;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;

import com.cirkana.Global;
import com.cirkana.viewer.comm.Communicator;

public class MapLocation {

	private static LocationListener locationListener;

	protected static LocationManager getLocationManager() {
		return (LocationManager) Global.getCurrentActivity().getSystemService(
				Context.LOCATION_SERVICE);
	}

	public static void start(String locationProvider, Communicator communicator) {
		locationListener = new MapLocationListener(communicator);
		getLocationManager().requestLocationUpdates(locationProvider, 0, 0,
				locationListener);

	}

	public static List<String> getLocationProviders() {
		return getLocationManager().getProviders(true);
	}

	public static Location getLastKnownLocation(String locationProvider) {
		return getLocationManager().getLastKnownLocation(locationProvider);
	}

	public static void changeLocation(Location location) {
		locationListener.onLocationChanged(location);
	}

}
